Dynamic Factor-Tilted Portfolio with Macro Stress Testing

Overview

This project dynamically constructs a factor-tilted portfolio using the Fama–French 5 Factor model. The historical factor data is sourced directly from Kenneth French’s website via web scraping. The portfolio adjusts its weights based on the current market regime (determined via SPY’s volatility and moving averages) and undergoes sophisticated stress testing with various market scenarios.

Features:

  • Market Regime Analysis: Uses SPY’s rolling volatility, moving averages, and RSI to determine the current market environment.

  • Dynamic Factor Tilting: Adjusts portfolio weights based on the identified market regime.

  • Advanced Risk Analysis: Calculates risk metrics including:
    • Monte Carlo simulations for VaR and CVaR (using Student’s t-distribution)

    • Traditional volatility, Sharpe ratio, and maximum drawdown

    • Higher-moment statistics like skewness and kurtosis

  • Sophisticated Stress Testing: Evaluates performance under various adverse scenarios with detailed modeling of:
    • Return impacts (multiplicative and additive effects)

    • Volatility scaling

    • Skewness adjustments

    • Tail behavior (kurtosis) modifications

  • Interactive Visualizations: Provides Plotly-based interactive charts for deeper analysis.

  • Automated Documentation: Builds a comprehensive site with Sphinx, including both static and interactive elements.

  • GitHub Pages Deployment: Automatically updates the site on a weekly schedule.

Portfolio Performance

If the interactive chart doesn’t load, you can view the static version below:

Portfolio Returns Plot

Factor Correlations

Understanding factor correlations is crucial for diversification and factor tilting:

If the interactive chart doesn’t load, you can view the static version below:

Factor Correlation Heatmap

Risk Profile Comparison

The radar chart below compares risk metrics across different stress scenarios:

If the interactive chart doesn’t load, you can view the static version below:

Risk Profile Radar Chart

Risk Metrics

The following interactive charts display the risk metrics computed for both the baseline portfolio and under different stress scenarios.

Annualized Volatility

Annualized Volatility

Sharpe Ratio

Sharpe Ratio

Value-at-Risk (95%)

VaR (95%)

Conditional Value-at-Risk (95%)

CVaR (95%)

Maximum Drawdown

Maximum Drawdown

Skewness

Skewness

Kurtosis

Kurtosis

How It Works

  1. Data and Factor Computation: The project scrapes Kenneth French’s [data library](https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html) to download the “F-F Research Data 5 Factors 2x3 Daily” dataset. Data is parsed and converted from percentages to decimals.

  2. Market Regime Analysis: SPY’s historical data is used to compute: - A 30-day rolling annualized volatility - 50-day and 200-day moving averages - 14-day Relative Strength Index (RSI)

    These metrics are then used to classify the market into regimes such as Expansion, Recession, Contraction, or Recovery.

  3. Dynamic Portfolio Construction: Based on the identified regime, the portfolio dynamically tilts its exposure among five factors: - MKT (Market premium) - SMB (Size premium) - HML (Value premium) - RMW (Profitability premium) - CMA (Investment premium)

  4. Monte Carlo Risk Analysis: VaR and CVaR are computed using Monte Carlo simulations with Student’s t-distributions (better for fat tails) to more accurately capture market risks compared to simple historical quantiles.

  5. Comprehensive Stress Testing: The portfolio undergoes sophisticated stress testing that models not just return impacts, but also: - Volatility scaling (accounts for heteroskedasticity during stress periods) - Skewness adjustments (captures asymmetric return distributions during crises) - Tail behavior modifications (models extreme events better than normal distributions)

Multiple stress scenarios model different market environments like severe recessions, rate hikes, market crashes, and corrections.

Indices and tables